﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace PhotoBook.Services
{
    public class StoreXmlTransformation : PhotoBook.Model.Services.IStore
    {
        #region IStore Members

        public void SaveTransformationToFile(PhotoBook.Model.Entities.FotoTransformation fotoTransformation, string file)
        {
            SaveTransformationToFile(fotoTransformation, System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None));            
        }

        public void SaveTransformationToFile(PhotoBook.Model.Entities.FotoTransformation fotoTransformation, System.IO.FileStream stream)
        {

            XmlSerializer serializer = new XmlSerializer(fotoTransformation.GetType());
            serializer.Serialize(stream, fotoTransformation);
            stream.Close();
        }

        #endregion
    }
}
